var sendOrder={
	map:null,
	localSearch:null,
	dialog:null,
	showOrderDialog:function(userids){
		var boss = this;
		boss.dialog = sbl.dialog({
			url:burl+"/OrderPushTModel/addView.do",
			width:"560px",
			height:"570px",
			OnComplete:function(){
				boss.initDialogEvent(boss);
				$("#order_userid").val(userids);
			}
		});
	},
	initDialogEvent:function(boss){
		
		boss.map = new BMap.Map("bmap");    
		boss.map.centerAndZoom(new BMap.Point(113.895367, 22.56343), 15);
		boss.map.addControl(new BMap.MapTypeControl());
		boss.map.enableScrollWheelZoom();
		
		boss.map.addEventListener("click", function(e){
			$("#orderAddress").val("地址解析中……");
			$("#orderPositionX").val(e.point.lng);
			$("#orderPositionY").val(e.point.lat);
			boss.loadAddress(e.point.lng,e.point.lat,"orderAddress");
		});
		
		boss.localSearch = new BMap.LocalSearch(boss.map, {
			renderOptions:{map: boss.map}
		});
		
		$("#sBtn").bind("click",function(){
			var keyWord = $("#localSearchAddr").val();
			boss.localSearch.search(keyWord);
		});
		
		$("#orderEndtime").datetimepicker();
		
		$("#sendOrderBtn").bind("click",function(){
			sbl.submit({
				url:burl+"/OrderPushTModel/add.do",
				data:"orderForm",
				success:function(d){
					alert("上传成功。");
					boss.dialog.remove();
				}
			});
		});
	},
	loadAddress:function(x,y,domid){
		
		var gc = new BMap.Geocoder(); 
		var point = new BMap.Point(x,y);
		
		 gc.getLocation(point, function(rs){				 	
	        var address = rs.address;
	        $("#"+domid).val(address);
		 });     
	},
};